//
//  Convert_timeZoneName.m
//  MacStockApp
//
//  Created by 英傑 翁 on 12/3/7.
//  Copyright (c) 2012年 翁英傑. All rights reserved.
//

#import "Convert_timeZoneName.h"

@implementation Convert_timeZoneName

-(NSString *)Google_Symbol_converTo_timeZoneWithName:(NSString*) symbol{
    symbol=[symbol uppercaseString];
    
    NSArray *code_array;
    code_array=[symbol componentsSeparatedByString:@":"];
    //標記:Add Target need Program 時區轉換
    
    
    if ([code_array count]==2) {
        //非美國國家交易所
        if ([[code_array objectAtIndex:0] isEqualToString:@"HKG"]) {
            //香港
            return @"Asia/Hong_Kong";
        }
        else if ([[code_array objectAtIndex:0] isEqualToString:@"TPE"]){
            //台灣
            return @"Asia/Taipei";
        }   
        else if ([[code_array objectAtIndex:0] isEqualToString:@"ASX"]  ){
            //澳洲
            return @"Australia/Sydney";
        } 
        else if ([[code_array objectAtIndex:0] isEqualToString:@"SHA"] || [[code_array objectAtIndex:0] isEqualToString:@"SHE"]){
            //中國
            return @"Asia/Shanghai";
        }  
        else if ([[code_array objectAtIndex:0] isEqualToString:@"TSE"] || [[code_array objectAtIndex:0] isEqualToString:@"CVE"]){
            //加拿大
            return @"America/Toronto";
        } 
        else if ([[code_array objectAtIndex:0] isEqualToString:@"FRA"] || [[code_array objectAtIndex:0] isEqualToString:@"ETR"]  || [[code_array objectAtIndex:0] isEqualToString:@"BIT"]   || [[code_array objectAtIndex:0] isEqualToString:@"EPR"] || [[code_array objectAtIndex:0] isEqualToString:@"ELI"] || [[code_array objectAtIndex:0] isEqualToString:@"AMS"]    ){
            //.歐洲
            return @"Europe/Berlin";
        }          
        else if ( [[code_array objectAtIndex:0] isEqualToString:@"NSE"]){
            //印度
            return @"Asia/Kolkata";
        }  
        else if ([[code_array objectAtIndex:0] isEqualToString:@"TYO"]  ){
            //日本
            return @"Asia/Tokyo";
        }
        
        else if ([[code_array objectAtIndex:0] isEqualToString:@"EPA"]  ){
            //法國
            return @"Europe/Paris";
        }           
        
        else{
            //如果 都沒有找到設定 就設定為 美國國家交易所
            return @"America/New_York";            
            
        }
    }
    else{
        //美國國家交易所
        return @"America/New_York";
    }
    
}
-(NSString *)Yahoo_Symbol_converTo_timeZoneWithName:(NSString*) symbol{
    symbol=[symbol uppercaseString];
    
    NSArray *code_array;
    code_array=[symbol componentsSeparatedByString:@"."];
    //標記:Add Target need Program 時區轉換
    
    
    if ([code_array count]==2) {
        //非美國國家交易所
        if ([[code_array objectAtIndex:1] isEqualToString:@"HK"]) {
            //香港
            return @"Asia/Hong_Kong";
        }
        else if ([[code_array objectAtIndex:1] isEqualToString:@"TW"] || [[code_array objectAtIndex:1] isEqualToString:@"TWO"]){
            //台灣
            return @"Asia/Taipei";
        }   
        else if ([[code_array objectAtIndex:1] isEqualToString:@"AX"]  ){
            //澳洲
            return @"Australia/Sydney";
        } 
        else if ([[code_array objectAtIndex:1] isEqualToString:@"SS"] || [[code_array objectAtIndex:1] isEqualToString:@"SZ"]){
            //中國
            return @"Asia/Shanghai";
        }  
        else if ([[code_array objectAtIndex:1] isEqualToString:@"TO"] || [[code_array objectAtIndex:1] isEqualToString:@"V"]){
            //加拿大
            return @"America/Toronto";
        } 
        else if ([[code_array objectAtIndex:1] isEqualToString:@"BE"] || [[code_array objectAtIndex:1] isEqualToString:@"BM"]  || [[code_array objectAtIndex:1] isEqualToString:@"DU"] || [[code_array objectAtIndex:1] isEqualToString:@"F"]  || [[code_array objectAtIndex:1] isEqualToString:@"HM"] || [[code_array objectAtIndex:1] isEqualToString:@"HA"] || [[code_array objectAtIndex:1] isEqualToString:@"MU"] || [[code_array objectAtIndex:1] isEqualToString:@"SG"] || [[code_array objectAtIndex:1] isEqualToString:@"DE"]  ){
            //德國
            return @"Europe/Berlin";
        }          
        else if ([[code_array objectAtIndex:1] isEqualToString:@"BO"] || [[code_array objectAtIndex:1] isEqualToString:@"NS"]){
            //印度
            return @"Asia/Kolkata";
        }  
        else if ([[code_array objectAtIndex:1] isEqualToString:@"KS"] || [[code_array objectAtIndex:1] isEqualToString:@"KQ"]){
            //韓國
            return @"Asia/Seoul";
        }
        else if ([[code_array objectAtIndex:1] isEqualToString:@"MI"]  ){
            //義大利
            return @"Europe/Rome";
        } 
        else if ([[code_array objectAtIndex:1] isEqualToString:@"NZ"]  ){
            //紐西蘭
            return @"Pacific/Auckland";
        } 
        else if ([[code_array objectAtIndex:1] isEqualToString:@"PA"] || [[code_array objectAtIndex:1] isEqualToString:@"NX"] ){
            //法國
            return @"Europe/Paris";
        }           
        else if ([[code_array objectAtIndex:1] isEqualToString:@"SA"]  ){
            //巴西
            return @"America/Sao_Paulo";
        }         
        else if ([[code_array objectAtIndex:1] isEqualToString:@"MX"]  ){
            //墨西哥
            return @"America/Mexico_City";
        }           
        else if ([[code_array objectAtIndex:1] isEqualToString:@"SI"]  ){
            //新加坡
            return @"Asia/Singapore";
        }          
        else if ([[code_array objectAtIndex:1] isEqualToString:@"L"]  ){
            //英國
            return @"Europe/London";
        }          
        else{
            //如果 都沒有找到設定 就設定為 美國國家交易所
            return @"America/New_York";            
            
        }
    }
    else{
        //美國國家交易所
        return @"America/New_York";
    }
    
}
-(NSString *)Bloomberg_Symbol_converTo_timeZoneWithName:(NSString*) symbol{
    symbol=[symbol uppercaseString];
    
    NSArray *code_array;
    code_array=[symbol componentsSeparatedByString:@":"];
    //標記:Add Target need Program 時區轉換
    
    
    if ([code_array count]==2) {
        //亞洲國家交易所
        if ([[code_array objectAtIndex:1] isEqualToString:@"HK"]) {
            //香港
            return @"Asia/Hong_Kong";
        }
        else if ([[code_array objectAtIndex:1] isEqualToString:@"TT"]  ){
            //台灣
            return @"Asia/Taipei";
        }   
        else if ([[code_array objectAtIndex:1] isEqualToString:@"AU"]  ){
            //澳洲
            return @"Australia/Sydney";
        } 
        else if ([[code_array objectAtIndex:1] isEqualToString:@"CH"]  ){
            //中國
            return @"Asia/Shanghai";
        }  
        else if ([[code_array objectAtIndex:1] isEqualToString:@"SP"]  ){
            //新加坡
            return @"Asia/Singapore";
        }   
        else if ([[code_array objectAtIndex:1] isEqualToString:@"KS"]  ){
            //韓國
            return @"Asia/Seoul";
        }
        else if ([[code_array objectAtIndex:1] isEqualToString:@"IN"]  ){
            //印度
            return @"Asia/Kolkata";
        }          
        else if ([[code_array objectAtIndex:1] isEqualToString:@"BD"]  ){
            //孟加拉
            return @"Asia/Dhaka";
        }   
        else if ([[code_array objectAtIndex:1] isEqualToString:@"FS"]  ){
            //斐濟
            return @"Pacific/Fiji";
        }           
        else if ([[code_array objectAtIndex:1] isEqualToString:@"IJ"]  ){
            //Indonesia
            return @"Asia/Jakarta";
        }             
        else if ([[code_array objectAtIndex:1] isEqualToString:@"JP"]  ){
            //日本
            return @"Asia/Tokyo";
        }             
        else if ([[code_array objectAtIndex:1] isEqualToString:@"MK"]  ){
            //馬來西亞
            return @"Asia/Kuala_Lumpur";
        }     
        else if ([[code_array objectAtIndex:1] isEqualToString:@"NZ"]  ){
            //紐西蘭
            return @"Pacific/Auckland";
        } 
        else if ([[code_array objectAtIndex:1] isEqualToString:@"PA"]  ){
            //巴基斯坦
            return @"Asia/Karachi";
        }            
        else if ([[code_array objectAtIndex:1] isEqualToString:@"PM"]  ){
            //菲律賓
            return @"Asia/Manila";
        }            
        else if ([[code_array objectAtIndex:1] isEqualToString:@"SL"]  ){
            //斯里蘭卡
            return @"Asia/Colombo";
        }            
        else if ([[code_array objectAtIndex:1] isEqualToString:@"TB"]  ){
            //泰國
            return @"Asia/Bangkok";
        }            
        else if ([[code_array objectAtIndex:1] isEqualToString:@"VN"]  ){
            //越南
            return @"Asia/Ho_Chi_Minh";
        }            
        //歐洲非洲 中亞國家交易所
        else if (  [[code_array objectAtIndex:1] isEqualToString:@"GR"]  ){
            //德國
            return @"Europe/Berlin";
        } 
        else if ([[code_array objectAtIndex:1] isEqualToString:@"LN"]  ){
            //英國
            return @"Europe/London";
        }           
        else if ([[code_array objectAtIndex:1] isEqualToString:@"FP"]   ){
            //法國
            return @"Europe/Paris";
        }            
        
        else if ([[code_array objectAtIndex:1] isEqualToString:@"AV"]  ){
            //Austria 奧地利  
            return @"Europe/Vienna";
        }           
        else if ([[code_array objectAtIndex:1] isEqualToString:@"BI"]  ){
            //Bahrain
            return @"Asia/Bahrain";
        }           
        else if ([[code_array objectAtIndex:1] isEqualToString:@"BB"]  ){
            //Belgium 比利時  
            return @"Europe/Brussels";
        }           
        else if ([[code_array objectAtIndex:1] isEqualToString:@"SG"]  ){
            //Belgrade
            return @"Europe/Belgrade";
        }           
        else if ([[code_array objectAtIndex:1] isEqualToString:@"BG"]  ){
            //Botswana
            return @"Africa/Gaborone";
        }        
        else if ([[code_array objectAtIndex:1] isEqualToString:@"BU"]  ){
            //Bulgaria
            return @"Europe/Sofia";
        }           
        else if ([[code_array objectAtIndex:1] isEqualToString:@"CZ"]  ){
            //Croatia
            return @"Europe/Zagreb";
        }           
        else if ([[code_array objectAtIndex:1] isEqualToString:@"CY"]  ){
            //Cyprus
            return @"Asia/Nicosia";
        }        
        else if ([[code_array objectAtIndex:1] isEqualToString:@"CP"]  ){
            //Czech Republic 捷克
            return @"Europe/Prague";
        }           
        else if ([[code_array objectAtIndex:1] isEqualToString:@"DC"]  ){
            //Denmark 丹麥
            return @"Europe/Copenhagen";
        }           
        else if ([[code_array objectAtIndex:1] isEqualToString:@"NM"]  ){
            //德國  Frankfurt
            return @"Europe/Berlin";
        }                
        else if ([[code_array objectAtIndex:1] isEqualToString:@"EY"]  ){
            //Egypt
            return @"Africa/Cairo";
        }        
        else if ([[code_array objectAtIndex:1] isEqualToString:@"ET"]  ){
            //Estonia
            return @"Europe/Tallinn";
        }           
        else if ([[code_array objectAtIndex:1] isEqualToString:@"FH"]  ){
            //Finland 芬蘭
            return @"Europe/Helsinki";
        }           
        else if ([[code_array objectAtIndex:1] isEqualToString:@"GN"]  ){
            //Ghana
            return @"Africa/Accra";
        }                  
        else if ([[code_array objectAtIndex:1] isEqualToString:@"GA"]  ){
            //Greece 希臘
            return @"Europe/Athens";
        }        
        else if ([[code_array objectAtIndex:1] isEqualToString:@"GU"]  ){
            //Guernsey
            return @"Europe/Guernsey";
        }           
        else if ([[code_array objectAtIndex:1] isEqualToString:@"HB"]  ){
            //Hungary 匈牙利
            return @"Europe/Budapest";
        }           
        else if ([[code_array objectAtIndex:1] isEqualToString:@"IR"]  ){
            //Iceland
            return @"Atlantic/Reykjavik";
        }             
        else if ([[code_array objectAtIndex:1] isEqualToString:@"ID"]  ){
            //Ireland
            return @"Europe/Dublin";
        }            
        else if ([[code_array objectAtIndex:1] isEqualToString:@"IT"]  ){
            //Israel
            return @"Asia/Jerusalem";
        }    
        else if ([[code_array objectAtIndex:1] isEqualToString:@"IM"]  ){
            //Italy
            return @"Europe/Rome";
        }             
        else if ([[code_array objectAtIndex:1] isEqualToString:@"JY"]  ){
            //Jersey
            return @"Europe/Jersey";
        }            
        else if ([[code_array objectAtIndex:1] isEqualToString:@"JR"]  ){
            //Jordan
            return @"Asia/Amman";
        }            
        else if ([[code_array objectAtIndex:1] isEqualToString:@"KK"]  ){
            //Kuwait 科威特
            return @"Asia/Kuwait";
        }    
        else if ([[code_array objectAtIndex:1] isEqualToString:@"LB"]  ){
            //Lebanon
            return @"Asia/Beirut";
        }             
        else if ([[code_array objectAtIndex:1] isEqualToString:@"LH"]  ){
            //Lithuania
            return @"Europe/Vilnius";
        }            
        else if ([[code_array objectAtIndex:1] isEqualToString:@"LX"]  ){
            //Luxembourg 盧森堡
            return @"Europe/Luxembourg";
        }            
        else if ([[code_array objectAtIndex:1] isEqualToString:@"MW"]  ){
            //Malawi
            return @"Africa/Blantyre";
        }    
        else if ([[code_array objectAtIndex:1] isEqualToString:@"MV"]  ){
            //Malta
            return @"Europe/Malta";
        }             
        else if ([[code_array objectAtIndex:1] isEqualToString:@"MP"]  ){
            //Mauritius
            return @"Indian/Mauritius";
        }            
        else if ([[code_array objectAtIndex:1] isEqualToString:@"MC"]  ){
            //Morocco 摩洛哥         
            return @"Africa/Casablanca";
        }            
        else if ([[code_array objectAtIndex:1] isEqualToString:@"NW"]  ){
            //Namibia
            return @"Africa/Windhoek";
        }    
        else if ([[code_array objectAtIndex:1] isEqualToString:@"NA"]  ){
            //Netherlands 荷蘭
            return @"Europe/Amsterdam";
        }             
        else if ([[code_array objectAtIndex:1] isEqualToString:@"NL"]  ){
            //Nigeria
            return @"Africa/Lagos";
        }            
        else if ([[code_array objectAtIndex:1] isEqualToString:@"NO"]  ){
            //Norway 挪威       
            
            return @"Europe/Oslo";
        }            
        else if ([[code_array objectAtIndex:1] isEqualToString:@"PA"]  ){
            //Pakistan
            return @"Asia/Karachi";
        }    
        else if ([[code_array objectAtIndex:1] isEqualToString:@"PS"]  ){
            //Palestine
            return @"Asia/Gaza";
        }             
        else if ([[code_array objectAtIndex:1] isEqualToString:@"PW"]  ){
            //Poland
            return @"Europe/Warsaw";
        }            
        else if ([[code_array objectAtIndex:1] isEqualToString:@"PL"]  ){
            //Portugal 葡萄牙
            return @"Europe/Lisbon";
        }            
        else if ([[code_array objectAtIndex:1] isEqualToString:@"QD"]  ){
            //Qatar
            return @"Asia/Qatar";
        }    
        else if ([[code_array objectAtIndex:1] isEqualToString:@"RO"]  ){
            //Romania 羅馬尼亞
            return @"PEurope/Bucharest";
        }             
        else if ([[code_array objectAtIndex:1] isEqualToString:@"RU"]  ){
            //Russia
            return @"Europe/Moscow";
        }            
        else if ([[code_array objectAtIndex:1] isEqualToString:@"SB"]  ){
            //Saudi Arabia 沙特阿拉伯
            return @"Asia/Riyadh";
        }            
        else if ([[code_array objectAtIndex:1] isEqualToString:@"SK"]  ){
            //Slovakia
            return @"Europe/Bratislava";
        }    
        else if ([[code_array objectAtIndex:1] isEqualToString:@"SV"]  ){
            //Slovenia
            return @"Europe/Ljubljana";
        }             
        else if ([[code_array objectAtIndex:1] isEqualToString:@"SJ"]  ){
            //South Africa
            return @"Africa/Johannesburg";
        }            
        else if ([[code_array objectAtIndex:1] isEqualToString:@"SM"]  ){
            //Spain
            return @"Europe/Madrid";
        }            
        else if ([[code_array objectAtIndex:1] isEqualToString:@"SD"]  ){
            //Swaziland 斯威士蘭
            return @"Africa/Mbabane";
        }    
        else if ([[code_array objectAtIndex:1] isEqualToString:@"SS"]  ){
            //Sweden 瑞典
            return @"Europe/Stockholm";
        }             
        else if ([[code_array objectAtIndex:1] isEqualToString:@"SW"]  ){
            // Switzerland 瑞士
            return @"Europe/Zurich";
        }            
        else if ([[code_array objectAtIndex:1] isEqualToString:@"TU"]  ){
            // Tunisia
            return @"Africa/Tunis";
        }            
        else if ([[code_array objectAtIndex:1] isEqualToString:@"UZ"]  ){
            //Turkey
            return @"Europe/Istanbul";
        }    
        else if ([[code_array objectAtIndex:1] isEqualToString:@"FS"]  ){
            //Ukraine 烏克蘭   
            return @"Europe/Kiev";
        }             
        else if ([[code_array objectAtIndex:1] isEqualToString:@"LI"]  ){
            //U.K. Intl
            return @"Europe/London";
        }            
        else if ([[code_array objectAtIndex:1] isEqualToString:@"ZL"]  ){
            //Zambia
            return @"Africa/Lusaka";
        }            
        else if ([[code_array objectAtIndex:1] isEqualToString:@"ZH"]  ){
            //Zimbabwe
            return @"Africa/Harare";
        }  
        
        //美洲國家交易所
        else if ([[code_array objectAtIndex:1] isEqualToString:@"US"] || [[code_array objectAtIndex:1] isEqualToString:@"UN"] || [[code_array objectAtIndex:1] isEqualToString:@"UW"]){
            //US
            return @"America/New_York";
        }   
        else if ([[code_array objectAtIndex:1] isEqualToString:@"CN"]){
            //加拿大
            return @"America/Toronto";
        }         
        else if ([[code_array objectAtIndex:1] isEqualToString:@"BZ"]  ){
            //巴西
            return @"America/Sao_Paulo";
        } 
        else if ([[code_array objectAtIndex:1] isEqualToString:@"MM"]  ){
            //墨西哥
            return @"America/Mexico_City";
        }           
        else if ([[code_array objectAtIndex:1] isEqualToString:@"AR"]  ){
            //Argentina
            return @"America/Argentina/Buenos_Aires";
        }            
        else if ([[code_array objectAtIndex:1] isEqualToString:@"BM"]  ){
            //Bahamas
            return @"America/Nassau";
        }            
        else if ([[code_array objectAtIndex:1] isEqualToString:@"BA"]  ){
            //Barbados
            return @"America/Barbados";
        }    
        else if ([[code_array objectAtIndex:1] isEqualToString:@"BH"]  ){
            //Bermuda
            return @"Atlantic/Bermuda";
        }             
        else if ([[code_array objectAtIndex:1] isEqualToString:@"VB"]  ){
            //Bolivia
            return @"America/La_Paz";
        }            
        else if ([[code_array objectAtIndex:1] isEqualToString:@"KY"]  ){
            //Cayman
            return @"America/Cayman";
        }            
        else if ([[code_array objectAtIndex:1] isEqualToString:@"CI"]  ){
            //Chile
            return @"America/Santiago";
        }    
        else if ([[code_array objectAtIndex:1] isEqualToString:@"CB"]  ){
            //Colombia
            return @"America/Bogota";
        }            
        else if ([[code_array objectAtIndex:1] isEqualToString:@"CR"]  ){
            //Costa Rica
            return @"America/Costa_Rica";
        }    
        else if ([[code_array objectAtIndex:1] isEqualToString:@"ED"]  ){
            //Ecuador
            return @"America/Guayaquil";
        }             
        else if ([[code_array objectAtIndex:1] isEqualToString:@"JA"]  ){
            //Jamaica
            return @"America/Jamaica";
        }            
        else if ([[code_array objectAtIndex:1] isEqualToString:@"NC"]  ){
            //Nicaragua
            return @"America/Managua";
        }            
        else if ([[code_array objectAtIndex:1] isEqualToString:@"PP"]  ){
            //Panama
            return @"America/Panama";
        }            
        else if ([[code_array objectAtIndex:1] isEqualToString:@"PN"]  ){
            //Paraguay
            return @"America/Asuncion";
        }    
        else if ([[code_array objectAtIndex:1] isEqualToString:@"PE"]  ){
            //Peru
            return @"America/Lima";
        }             
        else if ([[code_array objectAtIndex:1] isEqualToString:@"TP"]  ){
            //Trinidad
            return @"America/Port_of_Spain";
        }            
        else if ([[code_array objectAtIndex:1] isEqualToString:@"UY"]  ){
            //Uruguay
            return @"America/Montevideo";
        }            
        else if ([[code_array objectAtIndex:1] isEqualToString:@"VC"]  ){
            //Venezuela
            return @"America/Caracas";
        }   
        else if ([[code_array objectAtIndex:1] isEqualToString:@"IND"]  ){
            //指數 目前設定為台北時間 不過以後要針對每個指數在特別指定 區域
            return @"Asia/Taipei";
        }           
        else{
            //如果 都沒有找到設定 就設定為 美國國家交易所
            return @"America/New_York";            
            
        }
    }
    else{
        //美國國家交易所
        return @"America/New_York";
    }
    
}

@end
